<template>
  <div class='container'>
    <el-dialog
    title="题目预览"
    :visible="isShowDialog"
    width="900px"
    @open="open"
    :before-close="handelClose">
    <el-row>
      <el-col :span="6">【题型】：{{questionTypeshow[myData.questionType]}}</el-col>
      <el-col :span="6">【编号】：{{myData.enterpriseID}}</el-col>
      <el-col :span="6">【难度】：{{difficultyshow[myData.difficulty]}}</el-col>
      <el-col :span="6">【标签】：{{myData.tags}}</el-col>
    </el-row>
    <el-row >
      <el-col :span="6">【学科】：{{myData.subjectName}}</el-col>
      <el-col :span="6">【目录】：{{myData.directoryName}}</el-col>
      <el-col :span="6">【方向】：{{myData.direction}}</el-col>
    </el-row>
    <hr>
    <el-row>
      <el-col  class="elcoltigan">
        【题干】：<div class="tigan" v-html="myData.question"></div>
        <div v-if="myData.questionType!=='3'">
        <div style="padding-bottom:5px">{{questionTypeshow[myData.questionType]}} 选项：（以下选中的选项为正确答案）</div>
        <div v-for="item in myData.options" :key="item.code" style="padding:8px 0">
          <el-radio v-if="myData.questionType==='1'" :value="item.isRight" :label="1">{{item.title}}</el-radio>
          <el-checkbox v-if="myData.questionType==='2'" :value="item.isRight?true:false" >{{item.title}}</el-checkbox>
        </div>
      </div>
      </el-col>
    </el-row>
    <hr>
    <el-row>
      <el-col style="padding:0;">
        【参考答案】：<el-button type="danger" size="small" @click="handelVedio">视频答案预览</el-button>
        <div>
          <video v-show="isVeido" :src="myData.videoURL" controls></video>
        </div>
      </el-col>
    </el-row>
    <hr>
    <el-row>
      <el-col  class="elcoltigan">
        【答案解析】：<span v-html="myData.answerID"></span>
      </el-col>
    </el-row>
    <hr>
    <el-row>
      <el-col  class="elcoltigan">
        【题目备注】：<span v-html="myData.remarks"></span>
      </el-col>
    </el-row>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="handelcloseDialog()">关 闭</el-button>
    </span>
  </el-dialog>
  </div>
</template>

<script>
import { detail } from '../../api/hmmm/questions'
export default {
  props:['data','isShowDialog'],
  data() {
    return {
      dialogVisible:false,
      myData:{},
      isVeido:false,
      difficultyshow:{
        "1":'普通',
        "2":'一般',
        "3":'困难',
      },
      questionTypeshow:{
        "1":'单选',
        "2":'多选',
        "3":'简答',
      }
    }
  },
  methods: {
    async open () {
      const res = await detail({ id: this.data.id })
      this.myData = res.data
    },
    // 关闭弹窗
    handelClose() {
      this.$emit('closeDialog')
      this.myData.videoURL = ""
    },
    handelcloseDialog() {
      this.$emit('closeDialog')
      this.isVeido = false
      this.myData.videoURL = ""
    },
    handelVedio() {
      this.isVeido = true
    }
  }
}
</script>

<style scoped lang='less'>

.el-col{
    padding: 10px 0;
    vertical-align: center;
  }
  .elcoltigan {
    padding-bottom: 0;
  }
.tigan {
  color: red;
}
video {
  margin-top:5px;
  width: 400px;
  height: 250px;
}

</style>
